
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8"></meta>
      <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
      <title>7.6.&nbsp;Load XML - Chapter&nbsp;7.&nbsp;Export / Import</title>
      <link rel="stylesheet" type="text/css" href="../../docbook.css"></link>
      <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,600,300italic"></link>
      <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/codemirror.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/theme/neo.min.css"></link>
      <link rel="stylesheet" type="text/css" href="../../css/chunked-base.css"></link>
      <link rel="stylesheet" type="text/css" href="../../css/extra.css"></link><script src="//code.jquery.com/jquery-1.12.4.js" type="text/javascript"></script><script src="//cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js" type="text/javascript"></script><script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script><script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/codemirror.min.js" type="text/javascript"></script><script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/addon/runmode/runmode.min.js" type="text/javascript"></script><script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/mode/cypher/cypher.min.js" type="text/javascript"></script><script src="../../javascript/datatable.js" type="text/javascript"></script><script src="../../javascript/colorize.js" type="text/javascript"></script><script src="../../javascript/tabs-for-chunked.js" type="text/javascript"></script><script src="../../javascript/mp-nav.js" type="text/javascript"></script><script src="../../javascript/versionswitcher.js" type="text/javascript"></script><script src="../../javascript/version.js" type="text/javascript"></script><script src="//s3-eu-west-1.amazonaws.com/alpha.neohq.net/docs/new-manual/assets/search.js" type="text/javascript"></script><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"></meta>
      <link rel="prev" href="../load-xls/" title="7.5.&nbsp;Loading Excel (XLS)"></link>
      <link rel="next" href="../load-html/" title="7.6.8.&nbsp;Load HTML"></link>
      <link rel="shortcut icon" href="https://neo4j.com/wp-content/themes/neo4jweb/favicon.ico"></link><script>
        $(document).ready(function() {
          CodeMirror.colorize();
          tabTheSource($('body'));
          var $header = $('header').first();
          $header.prepend(
            $('<a href="" id="logo"><img src="https://neo4j.com/wp-content/themes/neo4jweb/assets/images/neo4j-logo-2015.png" alt="Neo4j Logo"></img></a>')
          );
          var $sidebar = $('<div id="sidebar-wrapper"></div>');
          $.get('toc.html', function (d){
            $(d).appendTo($sidebar);
            highlightToc();
            highlightLibraryHeader();
          });
          $sidebar.insertAfter($('header').first());
        });
        </script></head>
   <body>
      <header>
         <div class="searchbox">
            <form id="search-form" class="search" name="search-form" role="search"><input id="search-form-input" name="q" title="search" type="search" lang="en" placeholder="Search Neo4j docs..." aria-label="Search Neo4j documentation" max-length="128" required="required"></input><input id="search-form-button" type="submit" value="Search"></input></form>
         </div>
         <ul class="documentation-library">
            <li><a href="https://neo4j.com/docs/operations-manual/current">Operations Manual</a></li>
            <li><a href="https://neo4j.com/docs/developer-manual/current/">Developer Manual</a></li>
            <li><a href="https://neo4j.com/docs/ogm-manual/current/">OGM Manual</a></li>
            <li><a href="https://neo4j.com/docs/graph-algorithms/current/">Graph Algorithms</a></li>
            <li><a href="https://neo4j-contrib.github.io/neo4j-apoc-procedures/3.4/">APOC</a></li>
            <li><a href="https://neo4j.com/docs/java-reference/current/">Java Reference</a></li>
         </ul>
         <nav id="header-nav"><span class="nav-previous"><a accesskey="p" href="../load-xls/"><span class="fa fa-long-arrow-left" aria-hidden="true"></span>Loading Excel (XLS)</a></span><span class="nav-current">
               <p class="nav-title hidden">7.6.&nbsp;Load XML</p></span><span class="nav-next"><a accesskey="n" href="../load-html/">Load HTML<span class="fa fa-long-arrow-right" aria-hidden="true"></span></a></span></nav>
      </header>
      <div id="search-results" class="hidden"></div>
      <section class="section" id="load-xml">
         <div class="titlepage">
            <div>
               <div>
                  <h2 class="title" style="clear: both"><a class="anchor" href="#load-xml"></a>7.6.&nbsp;Load XML
                  </h2>
               </div>
            </div>
         </div>
         <section class="section" id="_load_xml_introduction">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_load_xml_introduction"></a>7.6.1.&nbsp;Load XML Introduction
                     </h3>
                  </div>
               </div>
            </div>
            <p>Many existing (enterprise) applications, endpoints and files use XML as data exchange format.</p>
            <p>To make these datastructures available to Cypher, you can use <code class="literal">apoc.load.xml</code>.
               It takes a file or http URL and parses the XML into a map datastructure.
            </p>
            <div class="admonitionblock note">
               <table>
                  <tbody>
                     <tr>
                        <td class="icon"><i class="fa icon-note" title="note"></i></td>
                        <td class="content">
                           <p>in previous releases we&#8217;ve had <code class="literal">apoc.load.xmlSimple</code>. This is now deprecated and got superseeded by
                              <code class="literal">apoc.load.xml(url, [xPath], [config], true)</code>.Simple XML Format
                           </p>
                        </td>
                     </tr>
                  </tbody>
               </table>
            </div>
            <p>See the following usage-examples for the procedures.</p>
         </section>
         <section class="section" id="_example_file">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_example_file"></a>7.6.2.&nbsp;Example File
                     </h3>
                  </div>
               </div>
            </div>
            <p>"How do you access XML doc attributes in children fields ?"</p>
            <p>(Thanks Nicolas Rouyer)</p>
            <p>For example, if my XML file is the example <a class="link" href="https://msdn.microsoft.com/en-us/library/ms762271%28v=vs.85%29.aspx" target="_top">book.xml provided by Microsoft</a>.
            </p><pre class="programlisting highlight"><code data-lang="xml">&lt;?xml version="1.0"?&gt;
&lt;catalog&gt;
   &lt;book id="bk101"&gt;
      &lt;author&gt;Gambardella, Matthew&lt;/author&gt;
      &lt;title&gt;XML Developer's Guide&lt;/title&gt;
      &lt;genre&gt;Computer&lt;/genre&gt;
      &lt;price&gt;44.95&lt;/price&gt;
      &lt;publish_date&gt;2000-10-01&lt;/publish_date&gt;
      &lt;description&gt;An in-depth look at creating applications
      with XML.&lt;/description&gt;
   &lt;/book&gt;
   &lt;book id="bk102"&gt;
      &lt;author&gt;Ralls, Kim&lt;/author&gt;
      &lt;title&gt;Midnight Rain&lt;/title&gt;
      &lt;genre&gt;Fantasy&lt;/genre&gt;
      &lt;price&gt;5.95&lt;/price&gt;
      &lt;publish_date&gt;2000-12-16&lt;/publish_date&gt;
      &lt;description&gt;A former architect battles corporate zombies,
...</code></pre><p>We have the file here, <a class="link" href="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml" target="_top">on GitHub</a>.
            </p>
         </section>
         <section class="section" id="_simple_xml_format">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_simple_xml_format"></a>7.6.3.&nbsp;Simple XML Format
                     </h3>
                  </div>
               </div>
            </div>
            <p>In a simpler XML representation, each type of children gets it&#8217;s own entry within the parent map.
               The element-type as key is prefixed with "_" to prevent collisions with attributes.
            </p>
            <p>If there is a single element, then the entry will just have that element as value, not a collection.
               If there is more than one element there will be a list of values.
            </p>
            <p>Each child will still have its <code class="literal">_type</code> field to discern them.
            </p>
            <p>Here is the example file from above loaded with <code class="literal">apoc.load.xmlSimple</code></p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml", '', {}, true)</code></pre><pre class="programlisting highlight"><code data-lang="javascript">{_type: "catalog", _book: [
  {_type: "book", id: "bk101",
    _author: [{_type: "author", _text: "Gambardella, Matthew"},{_type: author, _text: "Arciniegas, Fabio"}],
    _title: {_type: "title", _text: "XML Developer's Guide"},
    _genre: {_type: "genre", _text: "Computer"},
    _price: {_type: "price", _text: "44.95"},
    _publish_date: {_type: "publish_date", _text: "2000-10-01"},
    _description: {_type: description, _text: An in-depth look at creating applications ....</code></pre><section class="section" id="_simple_xml_examples">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_simple_xml_examples"></a>7.6.3.1.&nbsp;Simple XML Examples
                        </h4>
                     </div>
                  </div>
               </div>
               <p><span class="formalpara-title">Example 1.&nbsp;</span>
                  
               </p><pre class="programlisting highlight"><code data-lang="cypher">WITH "https://maps.googleapis.com/maps/api/directions/xml?origin=Mertens%20en%20Torfsstraat%2046,%202018%20Antwerpen&amp;destination=Rubensstraat%2010,%202300%20Turnhout&amp;sensor=false&amp;mode=bicycling&amp;alternatives=false&amp;key=AIzaSyAPPIXGudOyHD_KAa2f_1l_QVNbsd_pMQs" AS url
CALL apoc.load.xmlSimple(url) YIELD value
RETURN value._route._leg._distance._value, keys(value), keys(value._route), keys(value._route._leg), keys(value._route._leg._distance._value)</code></pre><p>
                  
               </p>
               <div class="informalfigure">
                  <div class="mediaobject"><img src="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/docs/images/apoc.load.xmlSimple.ex1.png" width="800" alt="apoc.load.xmlSimple.ex1"></img></div>
               </div>
               <p><span class="formalpara-title">Example 2.&nbsp;</span>
                  
               </p><pre class="programlisting highlight"><code data-lang="cypher">WITH "https://maps.googleapis.com/maps/api/directions/xml?origin=Mertens%20en%20Torfsstraat%2046,%202018%20Antwerpen&amp;destination=Rubensstraat%2010,%202300%20Turnhout&amp;sensor=false&amp;mode=bicycling&amp;alternatives=false&amp;key=AIzaSyAPPIXGudOyHD_KAa2f_1l_QVNbsd_pMQs" AS url
CALL apoc.load.xmlSimple(url) YIELD value
UNWIND keys(value) AS key
RETURN key, apoc.meta.type(value[key]);</code></pre><p>
                  
               </p>
               <div class="informalfigure">
                  <div class="mediaobject"><img src="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/docs/images/apoc.load.xmlSimple.ex2.png" width="800" alt="apoc.load.xmlSimple.ex2"></img></div>
               </div>
            </section>
            <section class="section" id="_http_headers">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_http_headers"></a>7.6.3.2.&nbsp;HTTP Headers
                        </h4>
                     </div>
                  </div>
               </div>
               <p>You can provide a map of HTTP headers to the config property.</p><pre class="programlisting highlight"><code data-lang="cypher">WITH { `X-API-KEY`: 'abc123' } as headers,
WITH "https://myapi.com/api/v1/" AS url
CALL apoc.load.xml(url, '', { headers: headers }) YIELD value
UNWIND keys(value) AS key
RETURN key, apoc.meta.type(value[key]);</code></pre></section>
         </section>
         <section class="section" id="_xpath">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_xpath"></a>7.6.4.&nbsp;xPath
                     </h3>
                  </div>
               </div>
            </div>
            <p>It&#8217;s possible to define a xPath (optional) to selecting nodes from the XML document.</p>
            <section class="section" id="_xpath_example">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_xpath_example"></a>7.6.4.1.&nbsp;xPath Example
                        </h4>
                     </div>
                  </div>
               </div>
               <p>From the Microsoft&#8217;s book.xml file we can get only the books that have as <code class="literal">genre</code> Computer
               </p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml", '/catalog/book[genre=\"Computer\"]') yield value as book
WITH book.id as id, [attr IN book._children WHERE attr._type IN ['title','price'] | attr._text] as pairs
RETURN id, pairs[0] as title, pairs[1] as price</code></pre><div class="informalfigure">
                  <div class="mediaobject"><img src="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/docs/images/apoc.load.xml.xpath.png" width="800" alt="apoc.load.xml.xpath"></img></div>
               </div>
               <p>In this case we return only <code class="literal">id</code>, <code class="literal">title</code> and <code class="literal">prize</code> but we can return any other elements
               </p>
               <p>We can also return just a single specific element.
                  For example the <code class="literal">author</code> of the book with <code class="literal">id = bg102</code></p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml('https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml', '/catalog/book[@id="bk102"]/author') yield value as result
WITH result._text as author
RETURN author</code></pre><div class="informalfigure">
                  <div class="mediaobject"><img src="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/docs/images/apoc.load.xml.xpath2.png" width="800" alt="apoc.load.xml.xpath2"></img></div>
               </div>
            </section>
         </section>
         <section class="section" id="_load_xml_and_introspect">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_load_xml_and_introspect"></a>7.6.5.&nbsp;Load XML and Introspect
                     </h3>
                  </div>
               </div>
            </div>
            <p>Let&#8217;s just load it and see what it looks like.
               It&#8217;s returned as value map with nested <code class="literal">_type</code> and <code class="literal">_children</code> fields, per group of elements.
               Attributes are turned into map-entries.
               And each element into their own little map with <code class="literal">_type</code>, attributes and <code class="literal">_children</code> if applicable.
            </p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml")</code></pre><pre class="programlisting highlight"><code data-lang="javascript">{_type: catalog, _children: [
  {_type: book, id: bk101, _children: [
    {_type: author, _text: Gambardella, Matthew},
    {_type: title, _text: XML Developer's Guide},
    {_type: genre, _text: Computer},
    {_type: price, _text: 44.95},
    {_type: publish_date, _text: 2000-10-01},
    {_type: description, _text: An in-depth look at creating applications ....</code></pre><section class="section" id="_for_each_book_how_do_i_access_book_id">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_for_each_book_how_do_i_access_book_id"></a>7.6.5.1.&nbsp;For each book, how do I access book id ?
                        </h4>
                     </div>
                  </div>
               </div>
               <p>You can access attributes per element directly.</p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml") yield value as catalog
UNWIND catalog._children as book
RETURN book.id</code></pre><pre class="screen highlight"><code>&#9554;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9557;
&#9474;book.id&#9474;
&#9566;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9569;
&#9474;bk101  &#9474;
&#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
&#9474;bk102  &#9474;</code></pre></section>
            <section class="section" id="_for_each_book_how_do_i_access_book_author_and_title">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_for_each_book_how_do_i_access_book_author_and_title"></a>7.6.5.2.&nbsp;For each book, how do I access book author and title ?
                        </h4>
                     </div>
                  </div>
               </div>
               <section class="section" id="_filter_into_collection">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h5 class="title"><a class="anchor" href="#_filter_into_collection"></a>Filter into collection
                           </h5>
                        </div>
                     </div>
                  </div>
                  <p>You have to filter over the sub-elements  in the <code class="literal">_childrens</code> array in this case.
                  </p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml") yield value as catalog
UNWIND catalog._children as book
RETURN book.id, [attr IN book._children WHERE attr._type IN ['author','title'] | [attr._type, attr._text]] as pairs</code></pre><pre class="screen highlight"><code>&#9554;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9572;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9557;
&#9474;book.id&#9474;pairs                                                                   &#9474;
&#9566;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9578;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9569;
&#9474;bk101  &#9474;[[author, Gambardella, Matthew], [title, XML Developer's Guide]]        &#9474;
&#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
&#9474;bk102  &#9474;[[author, Ralls, Kim], [title, Midnight Rain]]                          &#9474;</code></pre></section>
               <section class="section" id="_how_do_i_return_collection_elements">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h5 class="title"><a class="anchor" href="#_how_do_i_return_collection_elements"></a>How do I return collection elements?
                           </h5>
                        </div>
                     </div>
                  </div>
                  <p>This is not too nice, we could also just have returned the values and then grabbed them out of the list, but that relies on
                     element-order.
                  </p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml") yield value as catalog
UNWIND catalog._children as book
WITH book.id as id, [attr IN book._children WHERE attr._type IN ['author','title'] | attr._text] as pairs
RETURN id, pairs[0] as author, pairs[1] as title</code></pre><pre class="screen highlight"><code>&#9554;&#9552;&#9552;&#9552;&#9552;&#9552;&#9572;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9572;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9557;
&#9474;id   &#9474;author              &#9474;title                         &#9474;
&#9566;&#9552;&#9552;&#9552;&#9552;&#9552;&#9578;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9578;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9569;
&#9474;bk101&#9474;Gambardella, Matthew&#9474;XML Developer's Guide         &#9474;
&#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
&#9474;bk102&#9474;Ralls, Kim          &#9474;Midnight Rain                 &#9474;</code></pre></section>
            </section>
         </section>
         <section class="section" id="_extracting_datastructures">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_extracting_datastructures"></a>7.6.6.&nbsp;Extracting Datastructures
                     </h3>
                  </div>
               </div>
            </div>
            <section class="section" id="_turn_pairs_into_map">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_turn_pairs_into_map"></a>7.6.6.1.&nbsp;Turn Pairs into Map
                        </h4>
                     </div>
                  </div>
               </div>
               <p>So better is to turn them into a map with <code class="literal">apoc.map.fromPairs</code></p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml") yield value as catalog
UNWIND catalog._children as book
WITH book.id as id, [attr IN book._children WHERE attr._type IN ['author','title'] | [attr._type, attr._text]] as pairs
CALL apoc.map.fromPairs(pairs) yield value
RETURN id, value</code></pre><pre class="screen highlight"><code>&#9554;&#9552;&#9552;&#9552;&#9552;&#9552;&#9572;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9557;
&#9474;id   &#9474;value                                                               &#9474;
&#9566;&#9552;&#9552;&#9552;&#9552;&#9552;&#9578;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9569;
&#9474;bk101&#9474;{author: Gambardella, Matthew, title: XML Developer's Guide}        &#9474;
&#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
&#9474;bk102&#9474;{author: Ralls, Kim, title: Midnight Rain}                          &#9474;
&#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
&#9474;bk103&#9474;{author: Corets, Eva, title: Maeve Ascendant}                       &#9474;</code></pre><section class="section" id="_return_individual_columns">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h5 class="title"><a class="anchor" href="#_return_individual_columns"></a>Return individual Columns
                           </h5>
                        </div>
                     </div>
                  </div>
                  <p>And now we can cleanly access the attributes from the map.</p><pre class="programlisting highlight"><code data-lang="cypher">call apoc.load.xml("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml") yield value as catalog
UNWIND catalog._children as book
WITH book.id as id, [attr IN book._children WHERE attr._type IN ['author','title'] | [attr._type, attr._text]] as pairs
CALL apoc.map.fromPairs(pairs) yield value
RETURN id, value.author, value.title</code></pre><pre class="screen highlight"><code>&#9554;&#9552;&#9552;&#9552;&#9552;&#9552;&#9572;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9572;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9557;
&#9474;id   &#9474;value.author        &#9474;value.title                   &#9474;
&#9566;&#9552;&#9552;&#9552;&#9552;&#9552;&#9578;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9578;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9569;
&#9474;bk101&#9474;Gambardella, Matthew&#9474;XML Developer's Guide         &#9474;
&#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
&#9474;bk102&#9474;Ralls, Kim          &#9474;Midnight Rain                 &#9474;
&#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
&#9474;bk103&#9474;Corets, Eva         &#9474;Maeve Ascendant               &#9474;</code></pre></section>
            </section>
         </section>
         <section class="section" id="_import_xml_directly">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_import_xml_directly"></a>7.6.7.&nbsp;import xml directly
                     </h3>
                  </div>
               </div>
            </div>
            <p>In case you don&#8217;t want to transform your xml (like you do with <code class="literal">apoc.load.xml/apoc.load.xmlSimple</code> before you create nodes and relationships and you want to have a 1:1 mapping of xml into the graph you can use <code class="literal">apoc.xml.import</code>.
            </p>
            <section class="section" id="_usage_3">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_usage_3"></a>7.6.7.1.&nbsp;usage
                        </h4>
                     </div>
                  </div>
               </div><pre class="programlisting highlight"><code data-lang="cypher">CALL apoc.xml.import(&lt;url&gt;, &lt;config-map&gt;?) YIELD node</code></pre><p>The procedure will return a node representing the xml document containing nodes/rels underneath mapping to the xml structure.
                  The following mapping rules are applied:
               </p>
               <div class="informaltable">
                  <div class="table" id="d0e7417">
                     <table class="informaltable" border="1">
                        <colgroup>
                           <col class="col_1"></col>
                           <col class="col_2"></col>
                           <col class="col_3"></col>
                        </colgroup>
                        <thead>
                           <tr>
                              <th style="text-align: left; vertical-align: top; ">xml</th>
                              <th style="text-align: left; vertical-align: top; ">label</th>
                              <th style="text-align: left; vertical-align: top; ">properties</th>
                           </tr>
                        </thead>
                        <tbody>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>document</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>XmlDocument</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>_xmlVersion, _xmlEncoding</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>processing instruction</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>XmlProcessingInstruction</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>_piData, _piTarget</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>Element/Tag</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>XmlTag</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>_name</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>Attribute</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>n/a</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>property in the XmlTag node</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>Text</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>XmlWord</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>for each word a separate node is created</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </div>
               </div>
               <p>The nodes for the xml document are connected:</p>
               <div class="informaltable">
                  <div class="table" id="d0e7483">
                     <table class="informaltable" border="1">
                        <colgroup>
                           <col class="col_1"></col>
                           <col class="col_2"></col>
                        </colgroup>
                        <thead>
                           <tr>
                              <th style="text-align: left; vertical-align: top; ">relationship type</th>
                              <th style="text-align: left; vertical-align: top; ">description</th>
                           </tr>
                        </thead>
                        <tbody>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>:IS_CHILD_OF</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>pointing to a nested xml element</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>:FIRST_CHILD_OF</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>pointing to the first child</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>:NEXT_SIBLING</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>pointing to the next xml element on the same nesting level</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>:NEXT</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>produces a linear chain through the full document</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>:NEXT_WORD</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>only produced if config map has <code class="literal">createNextWordRelationships:true</code>. Connects words in xml to a text flow.
                                 </p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </div>
               </div>
               <p>The following options are available for the <code class="literal">config</code> map:
               </p>
               <div class="informaltable">
                  <div class="table" id="d0e7537">
                     <table class="informaltable" border="1">
                        <colgroup>
                           <col class="col_1"></col>
                           <col class="col_2"></col>
                           <col class="col_3"></col>
                        </colgroup>
                        <thead>
                           <tr>
                              <th style="text-align: left; vertical-align: top; ">config option</th>
                              <th style="text-align: left; vertical-align: top; ">default value</th>
                              <th style="text-align: left; vertical-align: top; ">description</th>
                           </tr>
                        </thead>
                        <tbody>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>connectCharacters</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>false</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>if <code class="literal">true</code> the xml text elements are child nodes of their tags, interconnected by relationships of type <code class="literal">relType</code> (see below)
                                 </p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>filterLeadingWhitespace</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>false</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>if <code class="literal">true</code> leading whitespace is skipped for each line
                                 </p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>delimiter</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p><code class="literal">\s</code> (regex whitespace)
                                 </p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>if given, split text elements with the delimiter into separate nodes</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>label</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>XmlCharacter</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>label to use for text element representation</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>relType</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p><code class="literal">NE</code></p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>relationship type to be used for connecting the text elements into one linked list</p>
                              </td>
                           </tr>
                           <tr>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>charactersForTag</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>{}</p>
                              </td>
                              <td style="text-align: left; vertical-align: top; ">
                                 <p>map of tagname &#8594; string. For the given tag names an additional text element is added containing the value as <code class="literal">text</code> property. Useful e.g. for <code class="literal">&lt;lb/&gt;</code> tags in TEI-XML to be represented as <code class="literal">&lt;lb&gt; &lt;/lb&gt;</code>.
                                 </p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </div>
               </div>
            </section>
            <section class="section" id="_example">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_example"></a>7.6.7.2.&nbsp;example
                        </h4>
                     </div>
                  </div>
               </div><pre class="programlisting highlight"><code data-lang="cypher">call
apoc.xml.import("https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/src/test/resources/xml/books.xml",{createNextWordRelationships:
true})
yield node
return node;

call apoc.xml.import('https://seafile.rlp.net/f/6282a26504cc4f079ab9/?dl=1', {connectCharacters: true, charactersForTag:{lb:' '}, filterLeadingWhitespace: true}) yield node
return node;</code></pre></section>
         </section>
         <section class="section" id="_config">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_config"></a>7.6.9.&nbsp;Config
                     </h3>
                  </div>
               </div>
            </div>
            <p>Config param is optional, the default value is an empty map.</p>
            <div class="informaltable">
               <div class="table" id="d0e7673">
                  <table class="informaltable" border="1">
                     <colgroup>
                        <col class="col_1"></col>
                        <col class="col_2"></col>
                     </colgroup>
                     <tbody>
                        <tr>
                           <td style="text-align: left; vertical-align: top; ">
                              <p><code class="literal">charset</code></p>
                           </td>
                           <td style="text-align: left; vertical-align: top; ">
                              <p>Default: UTF-8</p>
                           </td>
                        </tr>
                        <tr>
                           <td style="text-align: left; vertical-align: top; ">
                              <p><code class="literal">baserUri</code></p>
                           </td>
                           <td style="text-align: left; vertical-align: top; ">
                              <p>Default: "", it is use to resolve relative paths</p>
                           </td>
                        </tr>
                     </tbody>
                  </table>
               </div>
            </div>
         </section>
         <section class="section" id="_example_with_real_data">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_example_with_real_data"></a>7.6.10.&nbsp;Example with real data
                     </h3>
                  </div>
               </div>
            </div>
            <p>For these example we use the wikipedia home page "https://en.wikipedia.org/"</p>
            <section class="section" id="_examples">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_examples"></a>7.6.10.1.&nbsp;Examples
                        </h4>
                     </div>
                  </div>
               </div><pre class="programlisting highlight"><code data-lang="cypher">CALL apoc.load.html("https://en.wikipedia.org/",{metadata:"meta", h2:"h2"})</code></pre><p>You will get this result:</p>
               <div class="informalfigure">
                  <div class="mediaobject"><img src="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/docs/images/apoc.load.htmlall.png" width="800" alt="apoc.load.htmlall"></img></div>
               </div><pre class="programlisting highlight"><code data-lang="cypher">CALL apoc.load.html("https://en.wikipedia.org/",{links:"link"})</code></pre><p>You will get this result:</p>
               <div class="informalfigure">
                  <div class="mediaobject"><img src="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/docs/images/apoc.load.htmllinks.png" width="800" alt="apoc.load.htmllinks"></img></div>
               </div><pre class="programlisting highlight"><code data-lang="cypher">CALL apoc.load.html("https://en.wikipedia.org/",{metadata:"meta", h2:"h2"}, {charset: "UTF-8})</code></pre><p>You will get this result:</p>
               <div class="informalfigure">
                  <div class="mediaobject"><img src="https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/3.4/docs/images/apoc.load.htmlconfig.png" width="800" alt="apoc.load.htmlconfig"></img></div>
               </div>
            </section>
         </section>
         <section class="section" id="_example_2">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_example_2"></a>7.6.12.&nbsp;Example
                     </h3>
                  </div>
               </div>
            </div>
            <p>You can export your graph as an unweighted network.</p><pre class="programlisting highlight"><code data-lang="cypher">match path = (:Person)-[:ACTED_IN]-&gt;(:Movie)
WITH path LIMIT 1000
with collect(path) as paths
call apoc.gephi.add(null,'workspace0', paths) yield nodes, relationships, time
return nodes, relationships, time</code></pre><p>You can export your graph as a weighted network, by specifying the property of a relationship, that holds the weight value.</p><pre class="programlisting highlight"><code data-lang="cypher">match path = (:Person)-[r:ACTED_IN]-&gt;(:Movie) where exists r.weightproperty
WITH path LIMIT 1000
with collect(path) as paths
call apoc.gephi.add(null,'workspace0', paths, 'weightproperty') yield nodes, relationships, time
return nodes, relationships, time</code></pre><p>You can also export with your graph other properties of your nodes and/or relationship by adding an optional array with the
               property names you want to export.
               Example for exporting <code class="literal">birthYear</code> and <code class="literal">role</code> property.
            </p><pre class="programlisting highlight"><code data-lang="cypher">match path = (:Person)-[r:ACTED_IN]-&gt;(:Movie) where exists r.weightproperty
WITH path LIMIT 1000
with collect(path) as paths
call apoc.gephi.add(null,'workspace0', paths, 'weightproperty',['birthYear', 'role']) yield nodes, relationships, time
return nodes, relationships, time</code></pre><section class="section" id="_format">
               <div class="titlepage">
                  <div>
                     <div>
                        <h4 class="title"><a class="anchor" href="#_format"></a>7.6.12.1.&nbsp;Format
                        </h4>
                     </div>
                  </div>
               </div>
               <p>We send all nodes and relationships of the passed in data convert into individual Gephi-Streaming JSON fragements, separated
                  by <code class="literal">\r\n</code>.
               </p><pre class="programlisting highlight"><code data-lang="javascript">{"an":{"123":{"TYPE":"Person:Actor","label":"Tom Hanks",                           x:333,y:222,r:0.1,g:0.3,b:0.5}}}\r\n
{"an":{"345":{"TYPE":"Movie","label":"Forrest Gump",                               x:234,y:122,r:0.2,g:0.2,b:0.7}}}\r\n
{"ae":{"3344":{"TYPE":"ACTED_IN","label":"Tom Hanks",source:"123",target:"345","directed":true,"weight":1.0,r:0.1,g:0.3,b:0.5}}}</code></pre></section>
         </section>
         <section class="section" id="_specifics_details">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_specifics_details"></a>7.6.13.&nbsp;Specifics Details
                     </h3>
                  </div>
               </div>
            </div>
            <p>Gephi doesn&#8217;t render the graph data unless you also provide x,y coordinates in the payload, so we just send random ones within
               a 1000x1000 grid.
            </p>
            <p>We also generate colors per label combination and relationship-type, both of which are also transferred as <code class="literal">TYPE</code> property.
            </p>
            <p>You can have your weight property stored as a number (integer,float) or a string. If the weight property is invalid or null,
               it will use the default 1.0 value.
            </p>
         </section>
         <section class="section" id="_load_single_file_from_compressed_file_zip_tar_tar_gz_tgz">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_load_single_file_from_compressed_file_zip_tar_tar_gz_tgz"></a>7.6.14.&nbsp;Load Single File From Compressed File (zip/tar/tar.gz/tgz)
                     </h3>
                  </div>
               </div>
            </div>
            <p>For load file from compressed file the url right syntax is:</p><pre class="screen highlight"><code>apoc.load.csv("pathToFile!csv/fileName.csv")</code></pre><pre class="screen highlight"><code>apoc.load.json("https://github.com/neo4j-contrib/neo4j-apoc-procedures/tree/3.4/src/test/resources/testload.tgz?raw=true!person.json");</code></pre><p>You have to put the ! character before the filename.</p>
         </section>
         <section class="section" id="_using_s3_protocol">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_using_s3_protocol"></a>7.6.15.&nbsp;Using S3 protocol
                     </h3>
                  </div>
               </div>
            </div>
            <p>For using S3 protocol you have to copy these jars into the plugins directory:</p>
            <div class="itemizedlist">
               <ul class="itemizedlist" style="list-style-type: disc; ">
                  <li class="listitem">aws-java-sdk-core-1.11.250.jar (<a class="link" href="https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-core/1.11.250" target="_top">https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-core/1.11.250</a>)
                  </li>
                  <li class="listitem">aws-java-sdk-s3-1.11.250.jar (<a class="link" href="https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3/1.11.250" target="_top">https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3/1.11.250</a>)
                  </li>
                  <li class="listitem">httpclient-4.4.8.jar (<a class="link" href="https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.4" target="_top">https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.4</a>)
                  </li>
                  <li class="listitem">httpcore-4.5.4.jar (<a class="link" href="https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/4.4.8" target="_top">https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/4.4.8</a>)
                  </li>
                  <li class="listitem">joda-time-2.9.9.jar (<a class="link" href="https://mvnrepository.com/artifact/joda-time/joda-time/2.9.9" target="_top">https://mvnrepository.com/artifact/joda-time/joda-time/2.9.9</a>)
                  </li>
               </ul>
            </div>
            <p>S3 Url must be:</p>
            <div class="itemizedlist">
               <ul class="itemizedlist" style="list-style-type: disc; ">
                  <li class="listitem">s3://accessKey:secretKey@endpoint:port/bucket/key
                     or
                  </li>
                  <li class="listitem">s3://endpoint:port/bucket/key?accessKey=accessKey&amp;secretKey=secretKey</li>
               </ul>
            </div>
         </section>
         <section class="section" id="_failonerror">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_failonerror"></a>7.6.16.&nbsp;failOnError
                     </h3>
                  </div>
               </div>
            </div>
            <p>Adding on config the parameter <code class="literal">failOnError:false</code> (by default <code class="literal">true</code>), in case of error the procedure don&#8217;t fail but just return zero rows.
            </p>
         </section>
      </section>
      <footer><script type="text/javascript">
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
          //Allow Linker
          ga('create', 'UA-1192232-34','auto', {'allowLinker': true});
          ga('send', 'pageview');
          // Load the plugin.
          ga('require', 'linker');
          // Define which domains to autoLink.
          ga('linker:autoLink', ['neo4j.org','neo4j.com','neotechnology.com','graphdatabases.com','graphconnect.com']);
        </script><script type="text/javascript">
          document.write(unescape("%3Cscript src='//munchkin.marketo.net/munchkin.js' type='text/javascript'%3E%3C/script%3E"));
        </script><script>Munchkin.init('773-GON-065');</script></footer>
   </body>
</html>